package com.ruoyi.pcj.controller;

import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.annotation.Log;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pcj.domain.PcjPpRecords;
import com.ruoyi.pcj.service.IPcjPpRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 匹配-记录Controller
 * 
 * @author ms
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/pcj/records")
public class PcjPpRecordsController extends BaseController
{
    @Autowired
    private IPcjPpRecordsService pcjPpRecordsService;

    /**
     * 分页查询匹配-记录列表
     * @param params 最基本参数{"pageNum":1,"pageSize":10}，其他参数自行定义
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam Map<String, Object> params)
    {
        IPage<PcjPpRecords> page = pcjPpRecordsService.selectPcjPpRecordsList(params);
        return getDataTableMp(page);
    }



    /**
     * 导出匹配-记录列表
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:export')")
    @Log(title = "匹配-记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody Map<String, Object> params)
    {
        IPage<PcjPpRecords> page = pcjPpRecordsService.selectPcjPpRecordsList(params);
        ExcelUtil<PcjPpRecords> util = new ExcelUtil<PcjPpRecords>(PcjPpRecords.class);
        util.exportExcel(response, page.getRecords(), "匹配-记录数据");
    }

    /**
     * 获取匹配-记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(pcjPpRecordsService.selectPcjPpRecordsById(id));
    }

    /**
     * 新增匹配-记录
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:add')")
    @Log(title = "匹配-记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcjPpRecords pcjPpRecords)
    {
        return toAjax(pcjPpRecordsService.insertPcjPpRecords(pcjPpRecords));
    }

    /**
     * 修改匹配-记录
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:edit')")
    @Log(title = "匹配-记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcjPpRecords pcjPpRecords)
    {
        return toAjax(pcjPpRecordsService.updatePcjPpRecords(pcjPpRecords));
    }

    /**
     * 删除匹配-记录
     */
    @PreAuthorize("@ss.hasPermi('pcj:records:remove')")
    @Log(title = "匹配-记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(pcjPpRecordsService.deletePcjPpRecordsByIds(ids));
    }
}
